package cn.org.wifit.userserver.web.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.org.wifit.userserver.web.entity.Customer;
import cn.org.wifit.userserver.web.orm.iface.ICustomerDAO;

@Controller
public class CustomerAction {
	
	/**
	 * 
	 */
	@Autowired
	private ICustomerDAO<Customer> customerDAO;
	
	@ResponseBody
	@RequestMapping(value = "/test", method = RequestMethod.GET)
	public void test() throws Exception {
		System.out.println("12345678910.....");
	}
	
	@ResponseBody
	@RequestMapping(value = "/tesetInsert", method = RequestMethod.GET)
	public void tesetInsert() throws Exception {
		//构造一个customer对象
		Customer customer = new Customer();
		customer.setFirstName("rg54g45");
		customer.setLastName("g65656y6");
		customer.setId(String.valueOf(new Date().getTime()));
		customer.setSex(1);
		
		this.customerDAO.insert(customer);
	}
	
	@ResponseBody
	@RequestMapping(value = "/testQuery", method = RequestMethod.GET)
	public void testQuery() throws Exception {
		this.customerDAO.query(new Customer());
	}

	/**
	 * @return
	 */
	public ICustomerDAO<Customer> getCustomerDAO() {
		return customerDAO;
	}

	/**
	 * @param customerDAO
	 */
	public void setCustomerDAO(ICustomerDAO<Customer> customerDAO) {
		this.customerDAO = customerDAO;
	}
}
